package com.bjdd.jdy.entity;

import com.bigkoo.pickerview.model.IPickerViewData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/12.
 */

public class CityBean implements IPickerViewData{

    /**
     * cityId : 1
     * cityName : 福州市
     * cityCode : 3501
     * enable : true
     * areas : [{"areaId":2,"areaName":"台江区","areaCode":"350103","enable":true},{"areaId":1,"areaName":"鼓楼区","areaCode":"350102","enable":true}]
     */

    private int cityId;
    private String cityName;
    private String cityCode;
    private boolean enable;
    private List<AreaBean> areas;

    public static CityBean objectFromData(String str) {

        return new Gson().fromJson(str, CityBean.class);
    }

    public static List<CityBean> arrayCityBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<CityBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public int getCityId() {
        return cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public List<AreaBean> getAreas() {
        return areas;
    }

    public void setAreas(List<AreaBean> areas) {
        this.areas = areas;
    }


    @Override
    public String getPickerViewText() {
        return cityName;
    }
}
